#include "RightWidght.h"

#include <qpainter.h>
namespace UserManagementSystem {


RightWidght::RightWidght(QWidget *parent)
    :FramelessWidget(parent)
{

}

void RightWidght::LoadBackGround(const QString &path)
{
    m_background.load(path);
}

void RightWidght::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
    painter.setRenderHint(QPainter::SmoothPixmapTransform, true); // 开启高质量缩放

    // 计算目标大小（可保持宽高比）
    QSize targetSize = this->size(); // 也可以用 image.size() 保持原始大小

    // 绘制图片（保持缩放比例，居中）
    QPixmap scaled = m_background.scaled(targetSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
    QPoint center((width() - scaled.width()) / 2, (height() - scaled.height()) / 2);
    painter.drawPixmap(center, scaled);
}

};

